/**   
 * @Title: LotteryRecordAgp.java 
 * @Package com.esun.rabbit2.viewer.mainact.mylotteryact 
 * @Description: (购彩记录ActivityGroup 承载4个购彩记录列表) 
 * @Author: Billy qigs@500wan.com   
 * @Date: 2011-6-24 下午04:39:02  
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.viewer.mainact.mylotteryact.lotteryrecord;

import com.esun.config.Config;
import com.esun.network.ConnectionChangeReceiver;
import com.esun.ui.R;

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TabHost.TabSpec;

/**
 * @ClassName: LotteryRecordAgp
 * @Description: (购彩记录ActivityGroup)
 * @Author: Billy qigs@500wan.com
 * @Date: 2011-6-24 下午04:39:02
 */
public class LotteryRecordAgp extends ActivityGroup implements OnClickListener, OnCheckedChangeListener {

	private TabHost lotteryRecordTabHost;
	private ImageButton btnBack;
	private RadioButton rbAll;
	private RadioButton rbUndone;
	private RadioButton rbWinning;

	// private RadioButton rbShuangSeQiu;
	// private RadioButton rbDaLeTou;
	// private RadioButton rbShiYiXuanWu;
	// private RadioButton rbFootball;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.lotteryrecord_agp);

		lotteryRecordTabHost = (TabHost) findViewById(R.id.lotteryrecord_agp_tabhost);
		lotteryRecordTabHost.setup(LotteryRecordAgp.this.getLocalActivityManager());

		rbAll = (RadioButton) findViewById(R.id.lotteryrecord_agp_rb_all);
		rbAll.setOnClickListener(this);

		rbWinning = (RadioButton) findViewById(R.id.lotteryrecord_agp_rb_winning);
		rbWinning.setOnClickListener(this);

		rbUndone = (RadioButton) findViewById(R.id.lotteryrecord_agp_rb_undone);
		rbUndone.setOnClickListener(this);

		// rbShuangSeQiu = (RadioButton)
		// findViewById(R.id.lotteryrecord_agp_rb_shuangSeQiu);
		// rbShuangSeQiu.setOnClickListener(this);
		//
		// rbDaLeTou = (RadioButton)
		// findViewById(R.id.lotteryrecord_agp_rb_daLeTou);
		// rbDaLeTou.setOnClickListener(this);
		//
		// rbShiYiXuanWu = (RadioButton)
		// findViewById(R.id.lotteryrecord_agp_rb_shiYiXuanWu);
		// rbShiYiXuanWu.setOnClickListener(this);
		//
		// rbFootball = (RadioButton)
		// findViewById(R.id.lotteryrecord_agp_rb_football);
		// rbFootball.setOnClickListener(this);

		// 全部彩种标签
		TabSpec undoneRecordTS = lotteryRecordTabHost.newTabSpec("UNDONE_LOTTERYRECORD");
		undoneRecordTS.setIndicator(getResources().getString(R.string.shuangseqiu));
		undoneRecordTS.setContent(new Intent(this, LotteryRecordUndoneAct.class));
		lotteryRecordTabHost.addTab(undoneRecordTS);

		// 全部彩种标签
		TabSpec winningRecordTS = lotteryRecordTabHost.newTabSpec("WINNING_LOTTERYRECORD");
		winningRecordTS.setIndicator(getResources().getString(R.string.shuangseqiu));
		winningRecordTS.setContent(new Intent(this, LotteryRecordWinningAct.class));
		lotteryRecordTabHost.addTab(winningRecordTS);

		// 全部彩种标签
		TabSpec totalRecordTS = lotteryRecordTabHost.newTabSpec("TOTAL_LOTTERYRECORD");
		totalRecordTS.setIndicator(getResources().getString(R.string.shuangseqiu));
		totalRecordTS.setContent(new Intent(this, LotteryRecordTotalAct.class));
		lotteryRecordTabHost.addTab(totalRecordTS);
		// // 双色球
		// TabSpec shuangSeQiuRecordTS =
		// lotteryRecordTabHost.newTabSpec("SHUANGSEQIU_LOTTERYRECORD");
		// shuangSeQiuRecordTS.setIndicator(getResources().getString(R.string.shuangseqiu));
		// shuangSeQiuRecordTS.setContent(new Intent(this,
		// LotteryRecordShuangSeQiuAct.class));
		// lotteryRecordTabHost.addTab(shuangSeQiuRecordTS);
		// // 大乐透
		// TabSpec daLeTouRecordTS =
		// lotteryRecordTabHost.newTabSpec("DALETOU_LOTTERYRECORD");
		// daLeTouRecordTS.setIndicator(getResources().getString(R.string.daletou));
		// daLeTouRecordTS.setContent(new Intent(this,
		// LotteryRecordDaLeTouAct.class));
		// lotteryRecordTabHost.addTab(daLeTouRecordTS);
		// // 11选5
		// TabSpec shiYiXuanWuRecordTS =
		// lotteryRecordTabHost.newTabSpec("SHIYIXUANWU_LOTTERYRECORD");
		// shiYiXuanWuRecordTS.setIndicator(getResources().getString(R.string.shiyixuanwu));
		// shiYiXuanWuRecordTS.setContent(new Intent(this,
		// LotteryRecordShiYiXuanWuAct.class));
		// lotteryRecordTabHost.addTab(shiYiXuanWuRecordTS);
		// // 竞彩足球
		// TabSpec footballRecordTS =
		// lotteryRecordTabHost.newTabSpec("FOOTBALL_LOTTERYRECORD");
		// footballRecordTS.setIndicator(getResources().getString(R.string.football));
		// footballRecordTS.setContent(new Intent(this,
		// LotteryRecordFootballAct.class));
		// lotteryRecordTabHost.addTab(footballRecordTS);

		lotteryRecordTabHost.setCurrentTab(0);

		btnBack = (ImageButton) findViewById(R.id.lotteryrecord_agp_btn_back);
		btnBack.setOnClickListener(this);

		final TabWidget tab_widget = lotteryRecordTabHost.getTabWidget();
		int width = 45;
		int height = 50;

		for (int i = 0; i < tab_widget.getChildCount(); i++) {
			/**
			 * 设置高度、宽度，不过宽度由于设置为fill_parent，在此对它没效果
			 */
			tab_widget.getChildAt(i).getLayoutParams().height = height;
			tab_widget.getChildAt(i).getLayoutParams().width = width;
		}
	}

	public static boolean isCanClick = true;

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub

		Message msg = new Message();
		msg.what = Config.DO_REFRESH;

		switch (v.getId()) {
		case R.id.lotteryrecord_agp_rb_undone:
			if (isCanClick) {
				lotteryRecordTabHost.setCurrentTab(0);
				LotteryRecordUndoneAct.handlerGetTotalLotteryRecord.sendMessage(msg);
				isCanClick = false;
			}

			break;

		case R.id.lotteryrecord_agp_rb_winning:
			if (isCanClick) {
				lotteryRecordTabHost.setCurrentTab(1);
				LotteryRecordWinningAct.handlerGetTotalLotteryRecord.sendMessage(msg);
				isCanClick = false;
			}

			break;

		case R.id.lotteryrecord_agp_rb_all:
			if (isCanClick) {
				lotteryRecordTabHost.setCurrentTab(2);
				LotteryRecordTotalAct.handlerGetTotalLotteryRecord.sendMessage(msg);
				isCanClick = false;
			}

			break;

		// case R.id.lotteryrecord_agp_rb_shuangSeQiu:
		// if (isCanClick) {
		// lotteryRecordTabHost.setCurrentTab(1);
		// LotteryRecordShuangSeQiuAct.handlerGetShuangSeQiuLotteryRecord.sendMessage(msg);
		// isCanClick = false;
		// }
		//
		// break;
		//
		// case R.id.lotteryrecord_agp_rb_daLeTou:
		// if (isCanClick) {
		// lotteryRecordTabHost.setCurrentTab(2);
		// LotteryRecordDaLeTouAct.handlerGetDaLeTouLotteryRecord.sendMessage(msg);
		// isCanClick = false;
		// }
		//
		// break;
		//
		// case R.id.lotteryrecord_agp_rb_shiYiXuanWu:
		// if (isCanClick) {
		// lotteryRecordTabHost.setCurrentTab(3);
		// LotteryRecordShiYiXuanWuAct.handlerGetShiYiXuanWuLotteryRecord.sendMessage(msg);
		// isCanClick = false;
		// }
		//
		// break;
		//
		// case R.id.lotteryrecord_agp_rb_football:
		//
		// if (isCanClick) {
		// lotteryRecordTabHost.setCurrentTab(4);
		// LotteryRecordFootballAct.handlerGetFootballLotteryRecord.sendMessage(msg);
		// isCanClick = false;
		// }
		//
		// break;

		case R.id.lotteryrecord_agp_btn_back:

			LotteryRecordAgp.this.finish();

			break;

		default:

			break;

		}
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		this.unregisterReceiver(ConnectionChangeReceiver.getConnectionChangeReceiver());
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		this.registerReceiver(ConnectionChangeReceiver.getConnectionChangeReceiver(), ConnectionChangeReceiver.getIntentFilter());
	}

	@Override
	public void onCheckedChanged(RadioGroup group, int checkedId) {
		// TODO Auto-generated method stub

	}
}
